<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    li{
        list-style: none;
    }
</style>
<body>
    <div id="app">
        <ul>
            <li v-for="(book, index) in books" :key="index">{{book.name}}--{{book.price}}</li>
        </ul>
        <h1>总价格:{{totalPrice}}</h1>
    </div>
</body>
<script src="../js/http_cdn.bootcdn.net_ajax_libs_vue_2.6.6_vue.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            books:[
                {id:101,name:"Linux操作系统",price:123},
                {id:102,name:"windows操作系统",price:423},
                {id:103,name:"java变成思想",price:1153},
                {id:104,name:"深入JVM原理",price:513},
                {id:105,name:"深入SpringBoot",price:133},
            ]
        },
        computed: {
            totalPrice(){
                let res=0;
                for (const book of this.books) {
                    res+=book.price
                }
                return res;
            }
        },
    })
</script>
</html>
